import { SELECT_MENU, EXPAND_MENU, TOGGLE_MENU } from '../actionTypes'

const menus = {
	  system: {
	  	display: '系统管理',
	  	icon: 'appstore-o',
	  	submenu: {
	  		areaMechanism: {
	  			display: '区划/机构',
	  			icon: 'pie-chart',
	  			submenu: {
	  				area: {
	  					link: '/system/areaMechanism/area',
			        color: "#1f8dee",
			        display: '区划管理'
	  				},
	  				mechanism: {
	  					link: '/system/areaMechanism/organization',
	            color: "#00a220",
	  					display: '机构管理',
	  				}
	  			}
	      },
	      permission: {
	      	display: '权限管理',
	      	icon: 'solution',
	      	submenu: {
	      		list: {
			      	link: '/system/permission/list',
			        color: "#1f8dee",
			        display: '权限列表'
			      },
	      		role: {
			      	link: '/system/permission/role',
			        color: "#1f8dee",
			        display: '角色列表'
			      },
			      users: {
			      	link: '/system/permission/users',
			        color: "#1f8dee",
			        display: '用户列表'
			      },
			      townsUsers: {
			      	link: '/system/permission/townsUsers',
			        color: "#1f8dee",
			        display: '录入人员列表'
			      },
			      password: {
			      	link: '/system/permission/password',
			        color: "#1f8dee",
			        display: '修改密码'
			      }
	      	}
		  	},
	      dictionaryManage: {
	        display: '字典管理',
	        icon: 'credit-card',
	        submenu: {
	          dictionary: {
	            link: '/system/dictionaryManage/dictionary',
	            color: "#00a220",
	            display: '字典管理'
	          }
	        }
	      }
	  	}
	  },
	  data: {
	  	display: '业务数据',
	  	icon: 'calculator',
	  	submenu: {
	  		project: {
	  			display: '补贴项目管理',
	  			icon: 'book',
	  			submenu: {
	          category: {
	            link: '/data/project/category',
	            color: "#00a220",
	            display: '补贴分类管理'
	          },
	          list: {
	          	link: '/data/project/list',
	          	color: "#f40",
	            display: '补贴项目管理'
	          },
	          tag: {
	          	link: '/data/project/tag',
	          	color: "#f40",
	            display: '补贴标签管理'
	          },
	          dic: {
	          	link: '/data/project/dic',
	          	color: "#f40",
	            display: '补贴扩展属性管理'
	          }
	        }
	  		},
	  		citizen: {
	  			display: '辖内人员管理',
	  			icon: 'team',
	  			submenu: {
	          peopleMaintenance: {
	          	link: '/data/citizen/list',
	          	color: "#f40",
	            display: '人员信息维护'
	          }
	        }
	  		},
	  	}
	  },
	  projectRegister: {
	  	display: '项目登记',
	  	icon: 'message',
	  	submenu: {
	  		townsRegistingList: {
	  			link: '/projectRegister/townsRegistingList',
          color: "#00a220",
          display: '项目登记'
	  		},
	  		townsRegistedList: {
	  			link: '/projectRegister/townsRegistedList',
          color: "#00a220",
          display: '项目查看'
	  		},
	  		finishBatchList: {
	  			link: '/projectRegister/finishBatchList',
          color: "#00a220",
          display: '已完成查看'
	  		},
	  		townsAuditoringList: {
	  			link: '/projectRegister/townsAuditoringList',
          color: "#00a220",
          display: '补贴复核'
	  		},
	  		townsAuditoredList: {
	  			link: '/projectRegister/townsAuditoredList',
          color: "#00a220",
          display: '已提交上报'
	  		},
	  		orgAuditorList: {
	  			link: '/projectRegister/orgAuditorList',
          color: "#00a220",
          display: '主管部门审批'
	  		},
	  		orgBatchSummaryList: {
	  			link: '/projectRegister/orgBatchSummaryList',
          color: "#00a220",
          display: '主管部门上报'
	  		},
	  		financeAuditorList: {
	  			link: '/projectRegister/financeAuditorList',
          color: "#00a220",
          display: '财政部门审批'
	  		},
	  		financeAuditoredSummaryBatchList: {
	  			link: '/projectRegister/financeAuditoredSummaryBatchList',
          color: "#00a220",
          display: '代发文件下载'
	  		}
	  	}
	  }
}

const INIT_STATE = {
  menus,
  selectedKey: 'riskTrend',
  openKey: [],
  show: true
};

export default function reducer(state = INIT_STATE, { type, payload }) {
  switch (type) {
    case SELECT_MENU:
    {
      return Object.assign({}, state, { selectedKey: payload});
    }
    case EXPAND_MENU:
    {
      return payload
    }
    case TOGGLE_MENU:
    {
    	return Object.assign({}, state, { show: !state.show});
    }
    default:
      return state;
  }
}
